<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * Work with channels.
<span class='line'>  3</span>  *
<span class='line'>  4</span>  * The channel class provides methods for a client to establish a virtual
<span class='line'>  5</span>  *   connection - a channel - to a server and for both peers to operate the
<span class='line'>  6</span>  *   virtual connection thereafter.
<span class='line'>  7</span>  *
<span class='line'>  8</span>  * @name Channel
<span class='line'>  9</span>  * @exports Channel as api.Channel
<span class='line'> 10</span>  * @class
<span class='line'> 11</span>  */</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">Channel</span><span class="PUNC">(</span><span class="COMM">/**Channel*/</span><span class="NAME">handler</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 13</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">that</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT">    </span><span class="NAME">handler.addListener</span><span class="PUNC">(</span><span class="STRN">'Channel'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">frame</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 15</span> </span><span class="WHIT">        </span><span class="KEYW">switch</span><span class="PUNC">(</span><span class="NAME">frame.method.methodId</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 16</span> 
<span class='line'> 17</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">11</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="COMM">/**
<span class='line'> 19</span>  * Signal that the channel is ready.
<span class='line'> 20</span>  *
<span class='line'> 21</span>  * This method signals to the client that the channel is ready for use.
<span class='line'> 22</span>  *
<span class='line'> 23</span>  * @name Channel#openOk
<span class='line'> 24</span>  * @event
<span class='line'> 25</span>  * 
<span class='line'> 26</span>  */</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">            </span><span class="NAME">that.emit</span><span class="PUNC">(</span><span class="STRN">'openOk'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">frame</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="WHIT">            </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 29</span> 
<span class='line'> 30</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">20</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="COMM">/**
<span class='line'> 32</span>  * Enable/disable flow from peer.
<span class='line'> 33</span>  *
<span class='line'> 34</span>  * This method asks the peer to pause or restart the flow of content
<span class='line'> 35</span>  *     data. This is a simple flow-control mechanism that a peer can use
<span class='line'> 36</span>  *     to avoid oveflowing its queues or otherwise finding itself receiving
<span class='line'> 37</span>  *     more messages than it can process.  Note that this method is not
<span class='line'> 38</span>  *     intended for window control.  The peer that receives a request to
<span class='line'> 39</span>  *     stop sending content should finish sending the current content, if
<span class='line'> 40</span>  *     any, and then wait until it receives a Flow restart method.
<span class='line'> 41</span>  *
<span class='line'> 42</span>  * @name Channel#flow
<span class='line'> 43</span>  * @event
<span class='line'> 44</span>  * @param {Boolean} active If 1, the peer starts sending content frames.  If 0, the peer
<span class='line'> 45</span>  *       stops sending content frames.
<span class='line'> 46</span>  */</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">            </span><span class="NAME">that.emit</span><span class="PUNC">(</span><span class="STRN">'flow'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">frame</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT">            </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 49</span> 
<span class='line'> 50</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">21</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="COMM">/**
<span class='line'> 52</span>  * Confirm a flow method.
<span class='line'> 53</span>  *
<span class='line'> 54</span>  * Confirms to the peer that a flow command was received and processed.
<span class='line'> 55</span>  *
<span class='line'> 56</span>  * @name Channel#flowOk
<span class='line'> 57</span>  * @event
<span class='line'> 58</span>  * @param {Boolean} active Confirms the setting of the processed flow method: 1 means the
<span class='line'> 59</span>  *       peer will start sending or continue to send content frames; 0
<span class='line'> 60</span>  *       means it will not.
<span class='line'> 61</span>  */</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">            </span><span class="NAME">that.emit</span><span class="PUNC">(</span><span class="STRN">'flowOk'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">frame</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">            </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> 
<span class='line'> 65</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">30</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="COMM">/**
<span class='line'> 67</span>  * Send a non-fatal warning message.
<span class='line'> 68</span>  *
<span class='line'> 69</span>  * This method allows the server to send a non-fatal warning to the
<span class='line'> 70</span>  *     client.  This is used for methods that are normally asynchronous
<span class='line'> 71</span>  *     and thus do not have confirmations, and for which the server may
<span class='line'> 72</span>  *     detect errors that need to be reported.  Fatal errors are handled
<span class='line'> 73</span>  *     as channel or connection exceptions; non-fatal errors are sent
<span class='line'> 74</span>  *     through this method.
<span class='line'> 75</span>  *
<span class='line'> 76</span>  * @name Channel#alert
<span class='line'> 77</span>  * @event
<span class='line'> 78</span>  * @param {Number} replyCode The reply code. The AMQ reply codes are defined in AMQ RFC 011.
<span class='line'> 79</span>  * @param {String} replyText The localised reply text.  This text can be logged as an aid to
<span class='line'> 80</span>  *   resolving issues.
<span class='line'> 81</span>  * @param {Object} details A set of fields that provide more information about the
<span class='line'> 82</span>  *       problem.  The meaning of these fields are defined on a
<span class='line'> 83</span>  *       per-reply-code basis (TO BE DEFINED).
<span class='line'> 84</span>  */</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">            </span><span class="NAME">that.emit</span><span class="PUNC">(</span><span class="STRN">'alert'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">frame</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">            </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 87</span> 
<span class='line'> 88</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">40</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="COMM">/**
<span class='line'> 90</span>  * Request a channel close.
<span class='line'> 91</span>  *
<span class='line'> 92</span>  * This method indicates that the sender wants to close the channel.
<span class='line'> 93</span>  *     This may be due to internal conditions (e.g. a forced shut-down) or
<span class='line'> 94</span>  *     due to an error handling a specific method, i.e. an exception.  When
<span class='line'> 95</span>  *     a close is due to an exception, the sender provides the class and
<span class='line'> 96</span>  *     method id of the method which caused the exception.
<span class='line'> 97</span>  *
<span class='line'> 98</span>  * @name Channel#close
<span class='line'> 99</span>  * @event
<span class='line'>100</span>  * @param {Number} replyCode The reply code. The AMQ reply codes are defined in AMQ RFC 011.
<span class='line'>101</span>  * @param {String} replyText The localised reply text.  This text can be logged as an aid to
<span class='line'>102</span>  *   resolving issues.
<span class='line'>103</span>  * @param {Number} classId 
<span class='line'>104</span>  * @param {Number} methodId 
<span class='line'>105</span>  */</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">            </span><span class="NAME">that.emit</span><span class="PUNC">(</span><span class="STRN">'close'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">frame</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">            </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> 
<span class='line'>109</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">41</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>110</span> </span><span class="COMM">/**
<span class='line'>111</span>  * Confirm a channel close.
<span class='line'>112</span>  *
<span class='line'>113</span>  * This method confirms a Channel.Close method and tells the recipient
<span class='line'>114</span>  *     that it is safe to release resources for the channel and close the
<span class='line'>115</span>  *     socket.
<span class='line'>116</span>  *
<span class='line'>117</span>  * @name Channel#closeOk
<span class='line'>118</span>  * @event
<span class='line'>119</span>  * 
<span class='line'>120</span>  */</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">            </span><span class="NAME">that.emit</span><span class="PUNC">(</span><span class="STRN">'closeOk'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">frame</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">            </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> 
<span class='line'>124</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>126</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>127</span> </span><span class="NAME">require</span><span class="PUNC">(</span><span class="STRN">'sys'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">inherits</span><span class="PUNC">(</span><span class="NAME">Channel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">require</span><span class="PUNC">(</span><span class="STRN">'events'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">EventEmitter</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>128</span> 
<span class='line'>129</span> 
<span class='line'>130</span> </span><span class="COMM">/**
<span class='line'>131</span>  * Open a channel for use.
<span class='line'>132</span>  *
<span class='line'>133</span>  * This method opens a virtual connection (a channel).
<span class='line'>134</span>  *
<span class='line'>135</span>  * @name Channel#open
<span class='line'>136</span>  * @function
<span class='line'>137</span>  * @param {String} outOfBand Configures out-of-band transfers on this channel.  The syntax and
<span class='line'>138</span>  *       meaning of this field will be formally defined at a later date.
<span class='line'>139</span>  */</span><span class="WHIT">
<span class='line'>140</span> 
<span class='line'>141</span> </span><span class="COMM">/**
<span class='line'>142</span>  * Enable/disable flow from peer.
<span class='line'>143</span>  *
<span class='line'>144</span>  * This method asks the peer to pause or restart the flow of content
<span class='line'>145</span>  *     data. This is a simple flow-control mechanism that a peer can use
<span class='line'>146</span>  *     to avoid oveflowing its queues or otherwise finding itself receiving
<span class='line'>147</span>  *     more messages than it can process.  Note that this method is not
<span class='line'>148</span>  *     intended for window control.  The peer that receives a request to
<span class='line'>149</span>  *     stop sending content should finish sending the current content, if
<span class='line'>150</span>  *     any, and then wait until it receives a Flow restart method.
<span class='line'>151</span>  *
<span class='line'>152</span>  * @name Channel#flow
<span class='line'>153</span>  * @function
<span class='line'>154</span>  * @param {Boolean} active If 1, the peer starts sending content frames.  If 0, the peer
<span class='line'>155</span>  *       stops sending content frames.
<span class='line'>156</span>  */</span><span class="WHIT">
<span class='line'>157</span> 
<span class='line'>158</span> </span><span class="COMM">/**
<span class='line'>159</span>  * Confirm a flow method.
<span class='line'>160</span>  *
<span class='line'>161</span>  * Confirms to the peer that a flow command was received and processed.
<span class='line'>162</span>  *
<span class='line'>163</span>  * @name Channel#flowOk
<span class='line'>164</span>  * @function
<span class='line'>165</span>  * @param {Boolean} active Confirms the setting of the processed flow method: 1 means the
<span class='line'>166</span>  *       peer will start sending or continue to send content frames; 0
<span class='line'>167</span>  *       means it will not.
<span class='line'>168</span>  */</span><span class="WHIT">
<span class='line'>169</span> 
<span class='line'>170</span> </span><span class="COMM">/**
<span class='line'>171</span>  * Request a channel close.
<span class='line'>172</span>  *
<span class='line'>173</span>  * This method indicates that the sender wants to close the channel.
<span class='line'>174</span>  *     This may be due to internal conditions (e.g. a forced shut-down) or
<span class='line'>175</span>  *     due to an error handling a specific method, i.e. an exception.  When
<span class='line'>176</span>  *     a close is due to an exception, the sender provides the class and
<span class='line'>177</span>  *     method id of the method which caused the exception.
<span class='line'>178</span>  *
<span class='line'>179</span>  * @name Channel#close
<span class='line'>180</span>  * @function
<span class='line'>181</span>  * @param {Number} replyCode The reply code. The AMQ reply codes are defined in AMQ RFC 011.
<span class='line'>182</span>  * @param {String} replyText The localised reply text.  This text can be logged as an aid to
<span class='line'>183</span>  *   resolving issues.
<span class='line'>184</span>  * @param {Number} classId 
<span class='line'>185</span>  * @param {Number} methodId 
<span class='line'>186</span>  */</span><span class="WHIT">
<span class='line'>187</span> 
<span class='line'>188</span> </span><span class="COMM">/**
<span class='line'>189</span>  * Confirm a channel close.
<span class='line'>190</span>  *
<span class='line'>191</span>  * This method confirms a Channel.Close method and tells the recipient
<span class='line'>192</span>  *     that it is safe to release resources for the channel and close the
<span class='line'>193</span>  *     socket.
<span class='line'>194</span>  *
<span class='line'>195</span>  * @name Channel#closeOk
<span class='line'>196</span>  * @function
<span class='line'>197</span>  * 
<span class='line'>198</span>  */</span><span class="WHIT">
<span class='line'>199</span> 
<span class='line'>200</span> </span><span class="NAME">exports.Entity</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Channel</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>201</span> </span></pre></body></html>